import type { Component } from 'vue'

export function requireImage(path: string) {
  return new URL(`../../assets/image/${path}`, import.meta.url).href
}

/**
 * 2.将虚拟dom转换成真实dom
 * @param type true 返回挂载的 vue 实例 false/default 默认 dom innerHTML
 */
export function vNodeTransformDom(component: Component, type?: boolean) {
  // 不需要主动清空变量，GC回收
  const mountDom = document.createElement('div')
  const app = createApp(component)
  const realDom = app.mount(mountDom)
  return type ? mountDom : realDom.$el.outerHTML
}
